package com.hsc.yalebao.tabMine;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.text.format.DateUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.ILoadingLayout;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.hsc.yalebao.adapter.AccountChangeListAdapter;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.AmountRecordBaseModel;
import com.hsc.yalebao.model.AmountRecordModel;
import com.hsc.yalebao.model.UserBaseBean;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.ArrayList;
import java.util.HashMap;
import okhttp3.Call;

public class AccountChangeActivity extends BaseActivity
{
  private String TAG = "AccountChangeActivity";
  private AccountChangeListAdapter adapter;
  private View contentView;
  private Context context;
  private View emptyView;
  private boolean isEnd = false;
  private boolean isRefesh = true;
  int itemWidth;
  private ImageView iv_title_right;
  private PullToRefreshListView mPullRefreshListView;
  private int memberid;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      case 2131099704:
      default:
        return;
      case 2131099699:
      }
      CustomApplication.app.finishActivity(AccountChangeActivity.this);
    }
  };
  private int page = 1;
  private ArrayList<AmountRecordBaseModel> result = new ArrayList();
  int screenWidth;
  private TextView tv_tishi;
  private View view_title;

  private void getAmountRecordAndLossMoneyList()
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("memberid", this.memberid);
    localHashMap.put("pagesize", "10");
    localHashMap.put("page", this.page);
    localHashMap.put("startdate", "");
    localHashMap.put("enddate", "");
    Log.d(this.TAG, "URL:" + AppConstants.URL_GET_AOMUNT_RECORD_LIST);
    showLoadingDialog();
    RequestNet.get(this.context, AppConstants.URL_GET_AOMUNT_RECORD_LIST, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        AccountChangeActivity.this.dismissLoadingDialog();
        LogUtils.e(AccountChangeActivity.this.TAG, "获取失败,获取提现记录:" + paramAnonymousException);
        AccountChangeActivity.this.mPullRefreshListView.onRefreshComplete();
        AccountChangeActivity.this.mPullRefreshListView.setEmptyView(AccountChangeActivity.this.emptyView);
      }

      public void onResponse(String paramAnonymousString)
      {
        AccountChangeActivity.this.dismissLoadingDialog();
        AccountChangeActivity.this.mPullRefreshListView.onRefreshComplete();
        LogUtils.d(AccountChangeActivity.this.TAG, "result:数据" + paramAnonymousString);
        if (UiUtil.IsValueEmpty(paramAnonymousString))
        {
          LogUtils.d(AccountChangeActivity.this.TAG, "为空时result:" + paramAnonymousString);
          AccountChangeActivity.this.mPullRefreshListView.setEmptyView(AccountChangeActivity.this.emptyView);
        }
        AmountRecordModel localAmountRecordModel;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localAmountRecordModel = (AmountRecordModel)localGson.fromJson(paramAnonymousString, AmountRecordModel.class);
            if (localAmountRecordModel == null)
            {
              LogUtils.e(AccountChangeActivity.this.TAG, "getCurrSecond-issueTimeBean == null，获取失败");
              AccountChangeActivity.this.mPullRefreshListView.setEmptyView(AccountChangeActivity.this.emptyView);
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localAmountRecordModel = null;
            }
            if (localAmountRecordModel.getFlag() == 0)
            {
              LogUtils.e(AccountChangeActivity.this.TAG, "getPreProfitAndLossMoneyModel.getFlag() != 1&&-2");
              AccountChangeActivity.this.mPullRefreshListView.setEmptyView(AccountChangeActivity.this.emptyView);
              return;
            }
            if (localAmountRecordModel.getFlag() == -2)
            {
              AccountChangeActivity.this.showDownWireDialog();
              return;
            }
            if (localAmountRecordModel.getFlag() == -3)
            {
              AccountChangeActivity.this.ShowFengjinDialog();
              return;
            }
            if (localAmountRecordModel.getFlag() == -4)
            {
              AccountChangeActivity.activityStack.backToMain(MainActivity.class, AccountChangeActivity.this.context);
              return;
            }
          }
        }
        while (localAmountRecordModel.getFlag() != 1);
        if (localAmountRecordModel.getResult() == null)
        {
          LogUtils.e(AccountChangeActivity.this.TAG, "bean.getResult() == null");
          return;
        }
        AccountChangeActivity.this.result.addAll(localAmountRecordModel.getResult());
        if (AccountChangeActivity.this.result.size() == 0)
        {
          AccountChangeActivity.this.mPullRefreshListView.setEmptyView(AccountChangeActivity.this.emptyView);
          AccountChangeActivity.this.tv_tishi.setText("暂无账变记录");
        }
        LogUtils.e(AccountChangeActivity.this.TAG, "result.size():" + AccountChangeActivity.this.result.size());
        if (AccountChangeActivity.this.result.size() < 10);
        for (AccountChangeActivity.this.isEnd = true; ; AccountChangeActivity.this.isEnd = false)
        {
          AccountChangeActivity.this.adapter.setData(AccountChangeActivity.this.result);
          AccountChangeActivity.this.adapter.notifyDataSetChanged();
          return;
        }
      }
    });
  }

  private void init()
  {
    this.screenWidth = CustomApplication.app.displayMetrics.widthPixels;
    this.itemWidth = ((this.screenWidth - 2 * UiUtil.dip2px(this.context, 10.0F)) / 3);
    this.emptyView = LayoutInflater.from(this.context).inflate(2130903139, null);
    this.tv_tishi = ((TextView)this.emptyView.findViewById(2131100053));
    this.tv_tishi.setText("获取中...");
    this.mPullRefreshListView = ((PullToRefreshListView)findViewById(2131099717));
    this.mPullRefreshListView.setMode(PullToRefreshBase.Mode.BOTH);
    this.mPullRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener()
    {
      public void onRefresh(PullToRefreshBase<ListView> paramAnonymousPullToRefreshBase)
      {
        String str = DateUtils.formatDateTime(AccountChangeActivity.this.getApplicationContext(), System.currentTimeMillis(), 524305);
        paramAnonymousPullToRefreshBase.getLoadingLayoutProxy().setLastUpdatedLabel(str);
        if (AccountChangeActivity.this.mPullRefreshListView.isHeaderShown())
        {
          AccountChangeActivity.this.isRefesh = true;
          LogUtils.e(AccountChangeActivity.this.TAG, "mPullRefreshListView刷新");
          AccountChangeActivity.this.refeshAmountRecordAndLossMoneyList();
          return;
        }
        AccountChangeActivity.this.isRefesh = false;
        LogUtils.e(AccountChangeActivity.this.TAG, "mPullRefreshListView加载");
        if (AccountChangeActivity.this.isEnd)
          UiUtil.showToast(AccountChangeActivity.this.context, "暂无更多数据");
        AccountChangeActivity localAccountChangeActivity = AccountChangeActivity.this;
        localAccountChangeActivity.page = (1 + localAccountChangeActivity.page);
        AccountChangeActivity.this.getAmountRecordAndLossMoneyList();
      }
    });
    if (this.adapter == null)
    {
      this.adapter = new AccountChangeListAdapter(this.context, this.result);
      this.mPullRefreshListView.setAdapter(this.adapter);
    }
    this.adapter.notifyDataSetChanged();
  }

  private void refeshAmountRecordAndLossMoneyList()
  {
    this.page = 1;
    HashMap localHashMap = new HashMap();
    localHashMap.put("memberid", this.memberid);
    localHashMap.put("pagesize", "10");
    localHashMap.put("page", this.page);
    localHashMap.put("startdate", "");
    localHashMap.put("enddate", "");
    LogUtils.d(this.TAG, "URL:" + AppConstants.URL_GET_AOMUNT_RECORD_LIST);
    RequestNet.get(this.context, AppConstants.URL_GET_AOMUNT_RECORD_LIST, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        LogUtils.e(AccountChangeActivity.this.TAG, "获取失败,获取提现记录:" + paramAnonymousException);
        AccountChangeActivity.this.mPullRefreshListView.onRefreshComplete();
        AccountChangeActivity.this.mPullRefreshListView.setEmptyView(AccountChangeActivity.this.emptyView);
      }

      public void onResponse(String paramAnonymousString)
      {
        AccountChangeActivity.this.mPullRefreshListView.onRefreshComplete();
        LogUtils.d(AccountChangeActivity.this.TAG, "result:数据" + paramAnonymousString);
        if (UiUtil.IsValueEmpty(paramAnonymousString))
        {
          LogUtils.d(AccountChangeActivity.this.TAG, "为空时result:" + paramAnonymousString);
          AccountChangeActivity.this.mPullRefreshListView.setEmptyView(AccountChangeActivity.this.emptyView);
        }
        AmountRecordModel localAmountRecordModel;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localAmountRecordModel = (AmountRecordModel)localGson.fromJson(paramAnonymousString, AmountRecordModel.class);
            if (localAmountRecordModel == null)
            {
              LogUtils.e(AccountChangeActivity.this.TAG, "getCurrSecond-issueTimeBean == null，获取失败");
              AccountChangeActivity.this.mPullRefreshListView.setEmptyView(AccountChangeActivity.this.emptyView);
              AccountChangeActivity.this.tv_tishi.setText("获取失败");
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localAmountRecordModel = null;
            }
            if (localAmountRecordModel.getFlag() == 0)
            {
              LogUtils.e(AccountChangeActivity.this.TAG, "getPreProfitAndLossMoneyModel.getFlag() != 1&&-2");
              AccountChangeActivity.this.mPullRefreshListView.setEmptyView(AccountChangeActivity.this.emptyView);
              AccountChangeActivity.this.tv_tishi.setText("获取失败");
              return;
            }
            if (localAmountRecordModel.getFlag() == -2)
            {
              AccountChangeActivity.this.showDownWireDialog();
              return;
            }
            if (localAmountRecordModel.getFlag() == -3)
            {
              AccountChangeActivity.this.ShowFengjinDialog();
              return;
            }
            if (localAmountRecordModel.getFlag() == -4)
            {
              AccountChangeActivity.activityStack.backToMain(MainActivity.class, AccountChangeActivity.this.context);
              return;
            }
          }
        }
        while (localAmountRecordModel.getFlag() != 1);
        if (localAmountRecordModel.getResult() == null)
        {
          LogUtils.e(AccountChangeActivity.this.TAG, "bean.getResult() == null");
          return;
        }
        if (AccountChangeActivity.this.result != null)
          AccountChangeActivity.this.result.clear();
        AccountChangeActivity.this.result.addAll(localAmountRecordModel.getResult());
        if (AccountChangeActivity.this.result.size() == 0)
          AccountChangeActivity.this.mPullRefreshListView.setEmptyView(AccountChangeActivity.this.emptyView);
        LogUtils.e(AccountChangeActivity.this.TAG, "result.size():" + AccountChangeActivity.this.result.size());
        AccountChangeActivity.this.adapter.setData(AccountChangeActivity.this.result);
        AccountChangeActivity.this.adapter.notifyDataSetChanged();
      }
    });
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.context = this;
    setContentView(2130903041);
    CustomApplication.app.addActivity(this);
    setTitle(8, 0, 2130837809, "账变记录", 0, 8, 8, 0, true);
    init();
    if (CustomApplication.app.userBaseBean != null)
      this.memberid = CustomApplication.app.userBaseBean.getMemberid();
    getAmountRecordAndLossMoneyList();
  }

  protected void onResume()
  {
    super.onResume();
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    View localView = findViewById(2131099716);
    if (paramBoolean)
      localView.setVisibility(0);
    while (true)
    {
      ((TextView)localView.findViewById(2131099701)).setText(paramString);
      ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
      ImageView localImageView = (ImageView)localView.findViewById(2131099699);
      localImageView.setVisibility(paramInt2);
      localImageView.setOnClickListener(this.onClickListener);
      localImageView.setImageResource(paramInt3);
      TextView localTextView = (TextView)localView.findViewById(2131099702);
      localTextView.setVisibility(paramInt5);
      localTextView.setOnClickListener(this.onClickListener);
      this.iv_title_right = ((ImageView)localView.findViewById(2131099704));
      this.iv_title_right.setVisibility(paramInt6);
      this.iv_title_right.setOnClickListener(this.onClickListener);
      this.iv_title_right.setImageResource(paramInt7);
      return;
      localView.setVisibility(8);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tabMine.AccountChangeActivity
 * JD-Core Version:    0.6.2
 */